<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
	.item{
		width: 100px;
		display: inline-block;
		margin-left: 5px;
	}
</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
        	<td style="width:30%;">
        		<span class="item">产品名称(精确)：</span>
        		<div id="s_pro_name" emptyText="请选择..." class="mini-combobox" style="width:150px;margin-left:32px;"  popupWidth="165" textField="name" valueField="id" 
				    url="medical_medicine_view.do" multiSelect="true"  showClose="true" oncloseclick="onCloseClick" >     
				    <div property="columns">
				        <div header="产品名称" field="name"></div>
				    </div>
				</div>
            </td>
            <td style="width:30%;">
                <span class="item">媒体名称(精确)：</span>
                <div id="s_media_name" emptyText="请选择..." class="mini-combobox" style="width:150px;margin-left:28px;"  popupWidth="165" textField="name" valueField="id" 
				    url="medical_media_view_all.do" multiSelect="true"  showClose="true" oncloseclick="onCloseClick" >     
				    <div property="columns">
				        <div header="媒体名称" field="name"></div>
				    </div>
				</div>
            </td>
<!--                 <span style="margin-left:10px;">投放开始日期(大于)：</span> -->
<!--                 <input name="placeStartTime"  class="mini-datepicker" style="width: 150px" showClearButton="true" allowInput="false"/> -->
			<td style="white-space:nowrap;">
               	<a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
           	</td>
        </tr>
        <tr>
<!--         	<td style="width:100%;"> -->
<!--                 <span style="margin-left:10px;">投放开始日期(小于)：</span> -->
<!--                 <input name="placeEndTime" class="mini-datepicker" showClearButton="true" style="width: 150px" allowInput="false"/> -->
<!--             </td> -->
            
        </tr>
    </table>           
</div>
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
	    <table style="width:auto;">
	        <tr>
	            <td>
	            <sec:authorize url='/export_current_media_costs_data.do'>
					<a class="mini-button" iconCls="icon-download" onclick="exportCurrentData()">导出当前</a>
					<a class="mini-button" iconCls="icon-download" onclick="exportAllData()">导出所有</a>
				</sec:authorize>
	            </td>
	        </tr>
	    </table>           
	</div>
	<div class="mini-fit" >
		<div id="datagrid1" class="mini-datagrid " idField="id" pageSize="20"
			url="media_costs_views.do" style="width:100%;height:100%;" allowCellSelect="true" multiSelect="true">
			<div property="columns">
				<div type="indexcolumn" headerAlign="center">#</div>
				<div type="checkcolumn" headerAlign="center"></div>
				<div field="medicineName" width="100" headerAlign="center" align="center">产品名称</div>
				<div field="mediaName" width="100" headerAlign="center" align="center">媒体名称</div>
				<div field="putTime" width="100" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss" headerAlign="center" align="center">投放时间</div>
				<div field="inNum" width="100" headerAlign="center" align="center">进线数</div>
				<div field="dailyCost" width="100" headerAlign="center" align="center">日进线成本</div>
				<div field="orderNum" width="100" headerAlign="center" align="center">产品订单</div>
				<div field="orderCost" width="100" headerAlign="center" align="center">订单成本</div>
				<div field="effectiveCost" width="100" headerAlign="center" align="center">有效单成本</div>
				<div field="description" width="100" headerAlign="center" align="center">备注</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.reload();
	
	//查询
	function search() {
	    var medicineId = mini.get("s_pro_name").getValue();
	    var mediaId = mini.get("s_media_name").getValue();
	    var placeStartTime = mini.getbyName("placeStartTime").getFormValue();
	    var placeEndTime = mini.getbyName("placeEndTime").getFormValue();
	    grid.load({ medicineId: medicineId,
	    	mediaId: mediaId,
	    	placeStartTime: placeStartTime,
	    	placeEndTime: placeEndTime
	    });
	}
	
	//导出全部
	function exportAllData(){
		location.href="export_all_media_costs_data.do"; 
	}
	//导出当前页数据
	function exportCurrentData() {
		var data =grid.getData();
		var ids = [];
		$.each(data , function(){
	        ids.push(this.id);
	    });
		var id = ids.join(',');
		location.href="export_current_media_costs_data.do?ids=" +id;
	}
	
	function onCloseClick(e) {
        var obj = e.sender;
        obj.setText("");
        obj.setValue("");
    }
	
</script>
</body>
</html>